package org.example.top40;

public class main03 {
    //反转链表
    public static void main(String[] args) {
        ListNode node1 = new ListNode(1);
        ListNode node2 = new ListNode(2);
        ListNode node3 = new ListNode(3);
        node1.next=node2;
        node2.next=node3;
        ListNode cur=node1;
        ListNode pre=null;
        ListNode temp=null;
        while (cur!=null){
            temp=cur.next;
            cur.next=pre;
            pre=cur;
            cur=temp;
        }
        System.out.println(node2.next.val);

    }
}
